package com.basic;

import com.frame.struts.BaseBean;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.frame.struts.ActionContext;
import com.utils.*;
import java.util.Date;


/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2006</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class MainSaleRegionForm extends BaseBean {
    public MainSaleRegionForm() {
    }
	private String oldId = "";
	MainSaleRegionEntity msre = new MainSaleRegionEntity();
	public String addMainSaleRegion(){
		HttpServletRequest request = ActionContext.getActionContext().
			getRequest();
		HttpServletResponse response = ActionContext.getActionContext().
			getResponse();
		BasicFactory factory = new BasicFactory();
		//String qyid = (String) request.getSession().getAttribute("session_qyid");
		//msre.set/Qyid(qyid);
		msre.setOptdate(new Date());
		msre.setOptrid(CommUtil.getUserId(request));
		try{
		if(factory.addMainSaleRegion(msre)){
			//System.out.println("wo zhi xing le!");
			    response.sendRedirect("/basic/queryMainSaleRegion.jsp?cpid="+msre.getCpid());
				return "success";
		}
		response.sendRedirect("/basic/failed.jsp");
		}
		catch (Exception e) {

		}

			return "failed";
	}
	public String modifyMainSaleRegion(){
		HttpServletRequest request = ActionContext.getActionContext().
			getRequest();
		HttpServletResponse response = ActionContext.getActionContext().
			getResponse();
		BasicFactory factory = new BasicFactory();
		//String qyid = (String) request.getSession().getAttribute("session_qyid");
		//msre.set/Qyid(qyid);
		msre.setOptdate(new Date());
		msre.setOptrid(CommUtil.getUserId(request));
		System.out.println("khq="+msre.getKhq());
		factory.deleteMainSaleRegion(msre.getCpid(),this.getOldId());
        try{
		if(factory.addMainSaleRegion(msre)){
			//System.out.println("wo zhi xing le!");
			    response.sendRedirect("/basic/queryMainSaleRegion.jsp?cpid="+msre.getCpid());
				return "success";
		}
		response.sendRedirect("/basic/failed.jsp");
		}
		catch (Exception e) {

		}

		return "failed";
	}
	public String getOldId(){
		return this.oldId;
	}
	public void setOldId(String oldId){
		this.oldId=oldId;
	}

	/**
	 * @return msre.getReturns the cpid.
	 */
	public int getCpid() {
		return msre.getCpid();
	}
	/**
	 * @param cpid The cpid to set.
	 */
	public void setCpid(int cpid) {
		msre.setCpid(cpid);
	}
	/**
	 * @return msre.getReturns the gjzyl.
	 */
	public double getGjzyl() {
		return msre.getGjzyl();
	}
	/**
	 * @param gjzyl The gjzyl to set.
	 */
	public void setGjzyl(double gjzyl) {
		msre.setGjzyl(gjzyl);
	}
	/**
	 * @return msre.getReturns the khq.
	 */
	public String getKhq() {
		return msre.getKhq();
	}
	/**
	 * @param khq The khq to set.
	 */
	public void setKhq(String khq) {
		msre.setKhq(khq);
	}
	/**
	 * @return msre.getReturns the optdate.
	 */
	public Date getOptdate() {
		return msre.getOptdate();
	}
	/**
	 * @param optdate The optdate to set.
	 */
	public void setOptdate(Date optdate) {
		msre.setOptdate(optdate);
	}
	/**
	 * @return msre.getReturns the optrid.
	 */
	public String getOptrid() {
		return msre.getOptrid();
	}
	/**
	 * @param optrid The optrid to set.
	 */
	public void setOptrid(String optrid) {
		msre.setOptrid(optrid);
	}
	/**
	 * @return msre.getReturns the qymc.
	 */
	public String getQymc() {
		return msre.getQymc();
	}
	/**
	 * @param qymc The qymc to set.
	 */
	public void setQymc(String qymc) {
		msre.setQymc(qymc);
	}
	/**
	 * @return msre.getReturns the qyxse.
	 */
	public double getQyxse() {
		return msre.getQyxse();
	}
	/**
	 * @param qyxse The qyxse to set.
	 */
	public void setQyxse(double qyxse) {
		msre.setQyxse(qyxse);
	}
	/**
	 * @return msre.getReturns the recstate.
	 */
	public String getRecstate() {
		return msre.getRecstate();
	}
	/**
	 * @param recstate The recstate to set.
	 */
	public void setRecstate(String recstate) {
		msre.setRecstate(recstate);
	}
	/**
	 * @return msre.getReturns the remark.
	 */
	public String getRemark() {
		return msre.getRemark();
	}
	/**
	 * @param remark The remark to set.
	 */
	public void setRemark(String remark) {
		msre.setRemark(remark);
	}

}